\defmodule {ConstantGen}

This class implements a random variate generator
that returns a constant value.
Its mass function is
\begin{latexonly}
\eq
   p(x) = \left\{\begin{array}{ll}
     1, &  \qquad \mbox {for } x = c,\\[5pt]
     0, &  \qquad\mbox {elsewhere. }
  \end{array}\right. \eqlabel{eq:randcons}
\endeq
\end{latexonly}
\begin{htmlonly}
\eq
   p(x) = 1,  \qquad \mbox {for } x = c,
\endeq
and $p(x) = 0$ elsewhere.
\end{htmlonly}%
\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        ConstantGen
 * Description:  random variate generator for a constant distribution
 * Environment:  Java
 * Software:     SSJ
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       Éric Buist
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;\begin{hide}
\end{hide}

public class ConstantGen extends RandomVariateGen \begin{hide} {
   private double val;
\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection* {Constructor}
\begin{code}

   public ConstantGen (double val)\begin{hide} {
      this.val = val;
   }\end{hide}
\end{code}
  \begin{tabb} Constructs a new constant generator returning the given value
\texttt{val}.
 \end{tabb}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsubsection* {Methods}

\begin{code}\begin{hide}
   @Override
   public double nextDouble() {
      return val;
   }

   @Override
   public void nextArrayOfDouble (double[] v, int start, int n) {
      for (int i = 0; i < n; i++)
         v[start + i] = val;
   }\end{hide}
\end{code}

\begin{hide}\begin{code}
}\end{code}
\end{hide}

